3.352 \(\int \frac{(a+b \sin (e+f x))^2 (A+B \sin (e+f x))}{(c+d \sin (e+f x))^2} \, dx\)

Optimal. Leaf size=199 \[ -\frac{2 (b c-a d) \left (a d^2 (A c-B d)-b \left (-A c^2 d+2 A d^3+2 B c^3-3 B c d^2\right )\right ) \tan ^{-1}\left (\frac{c \tan \left (\frac{1}{2} (e+f x)\right )+d}{\sqrt{c^2-d^2}}\right )}{d^3 f \left (c^2-d^2\right )^{3/2}}-\frac{(b c-a d)^2 (B c-A d) \cos (e+f x)}{d^2 f \left (c^2-d^2\right ) (c+d \sin (e+f x))}-\frac{b x (-2 a B d-A b d+2 b B c)}{d^3}-\frac{b^2 B \cos (e+f x)}{d^2 f} \]

[Out]

-((b*(2*b*B*c - A*b*d - 2*a*B*d)*x)/d^3) - (2*(b*c - a*d)*(a*d^2*(A*c - B*d) - b*(2*B*c^3 - A*c^2*d - 3*B*c*d^
2 + 2*A*d^3))*ArcTan[(d + c*Tan[(e + f*x)/2])/Sqrt[c^2 - d^2]])/(d^3*(c^2 - d^2)^(3/2)*f) - (b^2*B*Cos[e + f*x
])/(d^2*f) - ((b*c - a*d)^2*(B*c - A*d)*Cos[e + f*x])/(d^2*(c^2 - d^2)*f*(c + d*Sin[e + f*x]))

________________________________________________________________________________________

Rubi [A]  time = 0.580276, antiderivative size = 199, normalized size of antiderivative = 1., number of steps used = 6, number of rules used = 6, integrand size = 35, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.171, Rules used = {2988, 3023, 2735, 2660, 618, 204} \[ -\frac{2 (b c-a d) \left (a d^2 (A c-B d)-b \left (-A c^2 d+2 A d^3+2 B c^3-3 B c d^2\right )\right ) \tan ^{-1}\left (\frac{c \tan \left (\frac{1}{2} (e+f x)\right )+d}{\sqrt{c^2-d^2}}\right )}{d^3 f \left (c^2-d^2\right )^{3/2}}-\frac{(b c-a d)^2 (B c-A d) \cos (e+f x)}{d^2 f \left (c^2-d^2\right ) (c+d \sin (e+f x))}-\frac{b x (-2 a B d-A b d+2 b B c)}{d^3}-\frac{b^2 B \cos (e+f x)}{d^2 f} \]

Antiderivative was successfully verified.

[In]

Int[((a + b*Sin[e + f*x])^2*(A + B*Sin[e + f*x]))/(c + d*Sin[e + f*x])^2,x]

[Out]

-((b*(2*b*B*c - A*b*d - 2*a*B*d)*x)/d^3) - (2*(b*c - a*d)*(a*d^2*(A*c - B*d) - b*(2*B*c^3 - A*c^2*d - 3*B*c*d^
2 + 2*A*d^3))*ArcTan[(d + c*Tan[(e + f*x)/2])/Sqrt[c^2 - d^2]])/(d^3*(c^2 - d^2)^(3/2)*f) - (b^2*B*Cos[e + f*x
])/(d^2*f) - ((b*c - a*d)^2*(B*c - A*d)*Cos[e + f*x])/(d^2*(c^2 - d^2)*f*(c + d*Sin[e + f*x]))

Rule 2988

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])^2*((A_.) + (B_.)*sin[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*sin[(e_.)
 + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[((B*c - A*d)*(b*c - a*d)^2*Cos[e + f*x]*(c + d*Sin[e + f*x])^(n + 1))/
(f*d^2*(n + 1)*(c^2 - d^2)), x] - Dist[1/(d^2*(n + 1)*(c^2 - d^2)), Int[(c + d*Sin[e + f*x])^(n + 1)*Simp[d*(n
 + 1)*(B*(b*c - a*d)^2 - A*d*(a^2*c + b^2*c - 2*a*b*d)) - ((B*c - A*d)*(a^2*d^2*(n + 2) + b^2*(c^2 + d^2*(n +
1))) + 2*a*b*d*(A*c*d*(n + 2) - B*(c^2 + d^2*(n + 1))))*Sin[e + f*x] - b^2*B*d*(n + 1)*(c^2 - d^2)*Sin[e + f*x
]^2, x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 - b^2, 0] && NeQ[c^2 - d
^2, 0] && LtQ[n, -1]

Rule 3023

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*sin[(e_.) + (f_.)*(x_)] + (C_.)*sin[(e_.) + (
f_.)*(x_)]^2), x_Symbol] :> -Simp[(C*Cos[e + f*x]*(a + b*Sin[e + f*x])^(m + 1))/(b*f*(m + 2)), x] + Dist[1/(b*
(m + 2)), Int[(a + b*Sin[e + f*x])^m*Simp[A*b*(m + 2) + b*C*(m + 1) + (b*B*(m + 2) - a*C)*Sin[e + f*x], x], x]
, x] /; FreeQ[{a, b, e, f, A, B, C, m}, x] &&  !LtQ[m, -1]

Rule 2735

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])/((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(b*x)/d
, x] - Dist[(b*c - a*d)/d, Int[1/(c + d*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d
, 0]

Rule 2660

Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x]}, Dis
t[(2*e)/d, Subst[Int[1/(a + 2*b*e*x + a*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}, x] &&
 NeQ[a^2 - b^2, 0]

Rule 618

Int[((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> Dist[-2, Subst[Int[1/Simp[b^2 - 4*a*c - x^2, x], x]
, x, b + 2*c*x], x] /; FreeQ[{a, b, c}, x] && NeQ[b^2 - 4*a*c, 0]

Rule 204

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> -Simp[ArcTan[(Rt[-b, 2]*x)/Rt[-a, 2]]/(Rt[-a, 2]*Rt[-b, 2]), x] /
; FreeQ[{a, b}, x] && PosQ[a/b] && (LtQ[a, 0] || LtQ[b, 0])

Rubi steps

\begin{align*} \int \frac{(a+b \sin (e+f x))^2 (A+B \sin (e+f x))}{(c+d \sin (e+f x))^2} \, dx &=-\frac{(b c-a d)^2 (B c-A d) \cos (e+f x)}{d^2 \left (c^2-d^2\right ) f (c+d \sin (e+f x))}+\frac{\int \frac{-d \left (B (b c-a d)^2-A d \left (a^2 c+b^2 c-2 a b d\right )\right )-b (b B c-A b d-2 a B d) \left (c^2-d^2\right ) \sin (e+f x)+b^2 B d \left (c^2-d^2\right ) \sin ^2(e+f x)}{c+d \sin (e+f x)} \, dx}{d^2 \left (c^2-d^2\right )}\\ &=-\frac{b^2 B \cos (e+f x)}{d^2 f}-\frac{(b c-a d)^2 (B c-A d) \cos (e+f x)}{d^2 \left (c^2-d^2\right ) f (c+d \sin (e+f x))}+\frac{\int \frac{-d^2 \left (B (b c-a d)^2-A d \left (a^2 c+b^2 c-2 a b d\right )\right )-b d (2 b B c-A b d-2 a B d) \left (c^2-d^2\right ) \sin (e+f x)}{c+d \sin (e+f x)} \, dx}{d^3 \left (c^2-d^2\right )}\\ &=-\frac{b (2 b B c-A b d-2 a B d) x}{d^3}-\frac{b^2 B \cos (e+f x)}{d^2 f}-\frac{(b c-a d)^2 (B c-A d) \cos (e+f x)}{d^2 \left (c^2-d^2\right ) f (c+d \sin (e+f x))}-\frac{\left ((b c-a d) \left (a d^2 (A c-B d)-b \left (2 B c^3-A c^2 d-3 B c d^2+2 A d^3\right )\right )\right ) \int \frac{1}{c+d \sin (e+f x)} \, dx}{d^3 \left (c^2-d^2\right )}\\ &=-\frac{b (2 b B c-A b d-2 a B d) x}{d^3}-\frac{b^2 B \cos (e+f x)}{d^2 f}-\frac{(b c-a d)^2 (B c-A d) \cos (e+f x)}{d^2 \left (c^2-d^2\right ) f (c+d \sin (e+f x))}-\frac{\left (2 (b c-a d) \left (a d^2 (A c-B d)-b \left (2 B c^3-A c^2 d-3 B c d^2+2 A d^3\right )\right )\right ) \operatorname{Subst}\left (\int \frac{1}{c+2 d x+c x^2} \, dx,x,\tan \left (\frac{1}{2} (e+f x)\right )\right )}{d^3 \left (c^2-d^2\right ) f}\\ &=-\frac{b (2 b B c-A b d-2 a B d) x}{d^3}-\frac{b^2 B \cos (e+f x)}{d^2 f}-\frac{(b c-a d)^2 (B c-A d) \cos (e+f x)}{d^2 \left (c^2-d^2\right ) f (c+d \sin (e+f x))}+\frac{\left (4 (b c-a d) \left (a d^2 (A c-B d)-b \left (2 B c^3-A c^2 d-3 B c d^2+2 A d^3\right )\right )\right ) \operatorname{Subst}\left (\int \frac{1}{-4 \left (c^2-d^2\right )-x^2} \, dx,x,2 d+2 c \tan \left (\frac{1}{2} (e+f x)\right )\right )}{d^3 \left (c^2-d^2\right ) f}\\ &=-\frac{b (2 b B c-A b d-2 a B d) x}{d^3}-\frac{2 (b c-a d) \left (a d^2 (A c-B d)-b \left (2 B c^3-A c^2 d-3 B c d^2+2 A d^3\right )\right ) \tan ^{-1}\left (\frac{d+c \tan \left (\frac{1}{2} (e+f x)\right )}{\sqrt{c^2-d^2}}\right )}{d^3 \left (c^2-d^2\right )^{3/2} f}-\frac{b^2 B \cos (e+f x)}{d^2 f}-\frac{(b c-a d)^2 (B c-A d) \cos (e+f x)}{d^2 \left (c^2-d^2\right ) f (c+d \sin (e+f x))}\\ \end{align*}

Mathematica [A]  time = 1.5741, size = 188, normalized size = 0.94 \[ \frac{\frac{2 (b c-a d) \left (a d^2 (B d-A c)+b \left (-A c^2 d+2 A d^3+2 B c^3-3 B c d^2\right )\right ) \tan ^{-1}\left (\frac{c \tan \left (\frac{1}{2} (e+f x)\right )+d}{\sqrt{c^2-d^2}}\right )}{\left (c^2-d^2\right )^{3/2}}+b (e+f x) (2 a B d+A b d-2 b B c)+\frac{d (b c-a d)^2 (A d-B c) \cos (e+f x)}{(c-d) (c+d) (c+d \sin (e+f x))}+b^2 (-B) d \cos (e+f x)}{d^3 f} \]

Antiderivative was successfully verified.

[In]

Integrate[((a + b*Sin[e + f*x])^2*(A + B*Sin[e + f*x]))/(c + d*Sin[e + f*x])^2,x]

[Out]

(b*(-2*b*B*c + A*b*d + 2*a*B*d)*(e + f*x) + (2*(b*c - a*d)*(a*d^2*(-(A*c) + B*d) + b*(2*B*c^3 - A*c^2*d - 3*B*
c*d^2 + 2*A*d^3))*ArcTan[(d + c*Tan[(e + f*x)/2])/Sqrt[c^2 - d^2]])/(c^2 - d^2)^(3/2) - b^2*B*d*Cos[e + f*x] +
 (d*(b*c - a*d)^2*(-(B*c) + A*d)*Cos[e + f*x])/((c - d)*(c + d)*(c + d*Sin[e + f*x])))/(d^3*f)

________________________________________________________________________________________

Maple [B]  time = 0.156, size = 1246, normalized size = 6.3 \begin{align*} \text{result too large to display} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+b*sin(f*x+e))^2*(A+B*sin(f*x+e))/(c+d*sin(f*x+e))^2,x)

[Out]

-2/f/d/(c*tan(1/2*f*x+1/2*e)^2+2*tan(1/2*f*x+1/2*e)*d+c)/(c^2-d^2)*c^2*tan(1/2*f*x+1/2*e)*B*b^2+4/f/(c*tan(1/2
*f*x+1/2*e)^2+2*tan(1/2*f*x+1/2*e)*d+c)/(c^2-d^2)*c*tan(1/2*f*x+1/2*e)*B*a*b+2/f*d^2/(c*tan(1/2*f*x+1/2*e)^2+2
*tan(1/2*f*x+1/2*e)*d+c)/(c^2-d^2)/c*tan(1/2*f*x+1/2*e)*A*a^2-4/f*d/(c*tan(1/2*f*x+1/2*e)^2+2*tan(1/2*f*x+1/2*
e)*d+c)/(c^2-d^2)*tan(1/2*f*x+1/2*e)*A*a*b+4/f/d/(c*tan(1/2*f*x+1/2*e)^2+2*tan(1/2*f*x+1/2*e)*d+c)/(c^2-d^2)*B
*a*b*c^2-4/f/d^2/(c^2-d^2)^(3/2)*arctan(1/2*(2*c*tan(1/2*f*x+1/2*e)+2*d)/(c^2-d^2)^(1/2))*B*a*b*c^3+2/f/(c^2-d
^2)^(3/2)*arctan(1/2*(2*c*tan(1/2*f*x+1/2*e)+2*d)/(c^2-d^2)^(1/2))*A*a^2*c+8/f/(c^2-d^2)^(3/2)*arctan(1/2*(2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/(c^2-d^2)^(3/2)*arctan(1/2*(2*c*t
an(1/2*f*x+1/2*e)+2*d)/(c^2-d^2)^(1/2))*A*b^2*c+2/f*d/(c*tan(1/2*f*x+1/2*e)^2+2*tan(1/2*f*x+1/2*e)*d+c)/(c^2-d
^2)*A*a^2-2/f/(c*tan(1/2*f*x+1/2*e)^2+2*tan(1/2*f*x+1/2*e)*d+c)/(c^2-d^2)*B*a^2*c

________________________________________________________________________________________

Maxima [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*sin(f*x+e))^2*(A+B*sin(f*x+e))/(c+d*sin(f*x+e))^2,x, algorithm="maxima")

[Out]

Exception raised: ValueError

________________________________________________________________________________________

Fricas [B]  time = 2.23469, size = 2761, normalized size = 13.87 \begin{align*} \text{result too large to display} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*sin(f*x+e))^2*(A+B*sin(f*x+e))/(c+d*sin(f*x+e))^2,x, algorithm="fricas")

[Out]

[-1/2*(2*(2*B*b^2*c^6 - 4*B*b^2*c^4*d^2 + 2*B*b^2*c^2*d^4 - (2*B*a*b + A*b^2)*c^5*d + 2*(2*B*a*b + A*b^2)*c^3*
d^3 - (2*B*a*b + A*b^2)*c*d^5)*f*x + (2*B*b^2*c^5 - 3*B*b^2*c^3*d^2 - (2*B*a*b + A*b^2)*c^4*d + (A*a^2 + 4*B*a
*b + 2*A*b^2)*c^2*d^3 - (B*a^2 + 2*A*a*b)*c*d^4 + (2*B*b^2*c^4*d - 3*B*b^2*c^2*d^3 - (2*B*a*b + A*b^2)*c^3*d^2
 + (A*a^2 + 4*B*a*b + 2*A*b^2)*c*d^4 - (B*a^2 + 2*A*a*b)*d^5)*sin(f*x + e))*sqrt(-c^2 + d^2)*log(((2*c^2 - d^2
)*cos(f*x + e)^2 - 2*c*d*sin(f*x + e) - c^2 - d^2 + 2*(c*cos(f*x + e)*sin(f*x + e) + d*cos(f*x + e))*sqrt(-c^2
 + d^2))/(d^2*cos(f*x + e)^2 - 2*c*d*sin(f*x + e) - c^2 - d^2)) + 2*(2*B*b^2*c^5*d + A*a^2*d^6 - (2*B*a*b + A*
b^2)*c^4*d^2 + (B*a^2 + 2*A*a*b - 3*B*b^2)*c^3*d^3 - (A*a^2 - 2*B*a*b - A*b^2)*c^2*d^4 - (B*a^2 + 2*A*a*b - B*
b^2)*c*d^5)*cos(f*x + e) + 2*((2*B*b^2*c^5*d - 4*B*b^2*c^3*d^3 + 2*B*b^2*c*d^5 - (2*B*a*b + A*b^2)*c^4*d^2 + 2
*(2*B*a*b + A*b^2)*c^2*d^4 - (2*B*a*b + A*b^2)*d^6)*f*x + (B*b^2*c^4*d^2 - 2*B*b^2*c^2*d^4 + B*b^2*d^6)*cos(f*
x + e))*sin(f*x + e))/((c^4*d^4 - 2*c^2*d^6 + d^8)*f*sin(f*x + e) + (c^5*d^3 - 2*c^3*d^5 + c*d^7)*f), -((2*B*b
^2*c^6 - 4*B*b^2*c^4*d^2 + 2*B*b^2*c^2*d^4 - (2*B*a*b + A*b^2)*c^5*d + 2*(2*B*a*b + A*b^2)*c^3*d^3 - (2*B*a*b
+ A*b^2)*c*d^5)*f*x + (2*B*b^2*c^5 - 3*B*b^2*c^3*d^2 - (2*B*a*b + A*b^2)*c^4*d + (A*a^2 + 4*B*a*b + 2*A*b^2)*c
^2*d^3 - (B*a^2 + 2*A*a*b)*c*d^4 + (2*B*b^2*c^4*d - 3*B*b^2*c^2*d^3 - (2*B*a*b + A*b^2)*c^3*d^2 + (A*a^2 + 4*B
*a*b + 2*A*b^2)*c*d^4 - (B*a^2 + 2*A*a*b)*d^5)*sin(f*x + e))*sqrt(c^2 - d^2)*arctan(-(c*sin(f*x + e) + d)/(sqr
t(c^2 - d^2)*cos(f*x + e))) + (2*B*b^2*c^5*d + A*a^2*d^6 - (2*B*a*b + A*b^2)*c^4*d^2 + (B*a^2 + 2*A*a*b - 3*B*
b^2)*c^3*d^3 - (A*a^2 - 2*B*a*b - A*b^2)*c^2*d^4 - (B*a^2 + 2*A*a*b - B*b^2)*c*d^5)*cos(f*x + e) + ((2*B*b^2*c
^5*d - 4*B*b^2*c^3*d^3 + 2*B*b^2*c*d^5 - (2*B*a*b + A*b^2)*c^4*d^2 + 2*(2*B*a*b + A*b^2)*c^2*d^4 - (2*B*a*b +
A*b^2)*d^6)*f*x + (B*b^2*c^4*d^2 - 2*B*b^2*c^2*d^4 + B*b^2*d^6)*cos(f*x + e))*sin(f*x + e))/((c^4*d^4 - 2*c^2*
d^6 + d^8)*f*sin(f*x + e) + (c^5*d^3 - 2*c^3*d^5 + c*d^7)*f)]

________________________________________________________________________________________

Sympy [F(-1)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*sin(f*x+e))**2*(A+B*sin(f*x+e))/(c+d*sin(f*x+e))**2,x)

[Out]

Timed out

________________________________________________________________________________________

Giac [B]  time = 1.26617, size = 1048, normalized size = 5.27 \begin{align*} \text{result too large to display} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*sin(f*x+e))^2*(A+B*sin(f*x+e))/(c+d*sin(f*x+e))^2,x, algorithm="giac")

[Out]

(2*(2*B*b^2*c^4 - 2*B*a*b*c^3*d - A*b^2*c^3*d - 3*B*b^2*c^2*d^2 + A*a^2*c*d^3 + 4*B*a*b*c*d^3 + 2*A*b^2*c*d^3
- B*a^2*d^4 - 2*A*a*b*d^4)*(pi*floor(1/2*(f*x + e)/pi + 1/2)*sgn(c) + arctan((c*tan(1/2*f*x + 1/2*e) + d)/sqrt
(c^2 - d^2)))/((c^2*d^3 - d^5)*sqrt(c^2 - d^2)) - 2*(B*b^2*c^3*d*tan(1/2*f*x + 1/2*e)^3 - 2*B*a*b*c^2*d^2*tan(
1/2*f*x + 1/2*e)^3 - A*b^2*c^2*d^2*tan(1/2*f*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